/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn;

import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.util.Arrays;
import java.util.stream.Stream;

import static org.junit.jupiter.params.provider.Arguments.arguments;

/**
 * <p>Project: javase - Demo
 * <p>Powered by webrx On 2021-12-28 11:32:43
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Demo {
    @BeforeAll
    public static void myall() {
        System.out.println("beforeAll");
    }

    @BeforeEach
    public void init() {
        System.out.println("连接数据库");
    }

    @AfterEach
    public void close() {
        System.out.println("关闭数据库连接");
    }

    @Test
    @DisplayName("junit5 test example")
    public void t() {
        System.out.println("hello world");
    }

    @Test
    public void t1() {
        System.out.println(3 * 3);
    }

    @ParameterizedTest
    //@ValueSource(ints = {3, 6})
    @MethodSource("ss")
    @DisplayName("参数化测试2")
    public void t2(int a, int b) {
        System.out.println(a * b);
        //System.out.println(a[1] * a[0]);
        // Assertions.assertEquals(a[0] * a[1], 9);
    }

    static Stream<Arguments> ss() {
        return Stream.of(
                arguments(3, 6),
                arguments(7, 9)
        );
    }

}
